package demo1;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 具体装饰器：去除单词首尾空格
 */
public class TrimDecorator extends WordReaderDecorator {
    public TrimDecorator(WordReader wordReader) {
        super(wordReader);
    }

    @Override
    protected List<String> decorate(List<String> words) {
        List<String> trimmedWords = words.stream()
                .map(String::trim) // 去除首尾空格
                .collect(Collectors.toList());
        System.out.printf("装饰器-去空格：处理完成，列表：%s%n", trimmedWords);
        return trimmedWords;
    }
}
